package com.example.springiocdemo.controller;

import com.example.springiocdemo.entity.UserInfo;
import com.example.springiocdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;

@Controller //将对象存储到spring中
public class UserController {

    @Autowired
    public UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }
    //注入方法三：Setter方法注入
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

    public void sayHi(){
        System.out.println("Hi   UserController");
        userService.sayHi();
    }

}
